
import axios from 'axios';

/**
 * 仓库材料关系
 */
export class StoreMaterialService {
    // 分页查询列表
    static findStoreMaterials (queryParams) {
        return axios({
            url: '/restaurant/material/StoreMaterial/findStoreMaterials',
            method: 'POST',
            data: queryParams
        });
    }

    //根据ID查询指定的仓库材料关系
    static findStoreMaterial (storeMaterialId) {
        const query = {
            storeMaterialId
        }
        return axios({
            url: '/restaurant/material/StoreMaterial/findStoreMaterial',
            method: 'POST',
            params: query,
        });
    }

    //根据ID查询指定的仓库材料关系(包含外键名称)
    static findStoreMaterialForView (storeMaterialId) {
        const query = {
            storeMaterialId
        }
        return axios({
            url: '/restaurant/material/StoreMaterial/findStoreMaterialForView',
            method: 'POST',
            params: query,
        });
    }

    //根据ID查询指定的仓库材料关系(包含外键名称)
    static findStoreMaterialForEdit (storeMaterialId) {
        const query = {
            storeMaterialId
        }
        return axios({
            url: '/restaurant/material/StoreMaterial/findStoreMaterialForEdit',
            method: 'POST',
            params: query,
        });
    }

    //根据ID查询指定的仓库材料关系(只提取ID 和 Name)
    static findStoreMaterialsWithIdNameById (storeMaterialId) {
        const query = {
            storeMaterialId
        }
        return axios({
            url: '/restaurant/material/StoreMaterial/findStoreMaterialsWithIdNameById',
            method: 'POST',
            params: query,
        });
    }

    //根据名称查询仓库材料关系集合(只提取ID 和 Name)
    static findStoreMaterialsWithIdNameByName (storeMaterialName) {
        const query = {
            storeMaterialName
        }
        return axios({
            url: '/restaurant/material/StoreMaterial/findStoreMaterialsWithIdNameByName',
            method: 'POST',
            params: query,
        });
    }

  //通过订单修改保存库存记录
  static updateStoreMaterialByOrder (stockRecord) {
    const query = {}
    return axios({
      url: '/restaurant/material/StoreMaterial/updateStoreMaterialByOrder',
      method: 'POST',
      params: query,
      data: stockRecord
    });
  }

    //新增保存仓库材料关系
    static saveStoreMaterial (operation,storeMaterial) {
      //operation 0代表退库 1代表入库 2代表领用
        const query = {
          operation
        }
        return axios({
            url: '/restaurant/material/StoreMaterial/saveStoreMaterial',
            method: 'POST',
            params: query,
            data:storeMaterial
        });
    }

    //修改保存仓库材料关系
    static updateStoreMaterial (operation,storeMaterial) {
        const query = {
          operation
        }
        return axios({
            url: '/restaurant/material/StoreMaterial/updateStoreMaterial',
            method: 'POST',
            params: query,
            data:storeMaterial
        });
    }

    //根据ID查询指定的仓库材料关系(只提取ID 和 Name)
    static deleteStoreMaterial (storeMaterialId) {
        const query = {
            storeMaterialId
        }
        return axios({
            url: '/restaurant/material/StoreMaterial/deleteStoreMaterial',
            method: 'POST',
            params: query,
        });
    }
}
